home *** CD-ROM | disk | FTP | other *** search
- #include <exec/exec.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include "dh1:source/doors/romconf/doorheader.h"
- #include "dh0:code/aelib/ae_pragmas.h"
-
- char path[200];
- char VaultCfg[200];
- extern struct Library *AEBase;
- #define gu getuserstring
- #define pu putuserstring
- #define hk hotkey
- #define pm prompt
- #define sm sendmessage
- char name[50];
- char Password[6][80];
- int Security = 0;
- int VaultLevel =0;
- char temp[100];
- int tempsecure=0;
- void InitPass(void);
- void ShowIntro(void);
- int GetPass(int num);
- int Secure(char *s);
- int GetVaultLevel(void);
- void InitVault(void);
- void LastCommand(void);
- void end(void);
- int Verbose=FALSE;
- main(int argc,char *argv[])
- {
- register int i;
- if(argc!=2)
- {
- printf("\n");
- printf("Vault version 1.1 , written by Joseph Hodge\n");
- printf("This is a product of the /X Developement Team - The Silent Achievers\n");
- printf("This is a (XIM) for AmiExpress 2.1+\n");
- printf("\n");
- exit(0);
- }
- Register(argv[1][0]-'0');
- strcpy(path,argv[0]);
- i=strlen(path)-1;
- while(i)
- {
- if(path[i]==':' || path[i]=='/') {path[i+1]='\0'; break; }
- i--;
- }
- sprintf(VaultCfg,"%sVault.cfg",path);
- if(!TLock(VaultCfg))
- InitVault();
- VaultLevel=GetVaultLevel();
- gu(temp,DT_SECSTATUS);
- Security=atoi(temp);
- if(Security<VaultLevel) { ShutDown(); end(); }
- if(Security>VaultLevel) { sprintf(temp,"%d",VaultLevel); pu(temp,DT_SECSTATUS); }
- gu(name,DT_NAME); strupr(name);
- if(!Secure(name)) { sm("",1); ShutDown(); end(); }
- sprintf(temp,"%d",tempsecure);
- pu(temp,DT_SECSTATUS);
- sm("",1);
- ShutDown();
- end();
-
- }
-
- void end(void)
- {
- exit(0);
- }
- void LastCommand(void)
- {
- }
- void InitVault(void)
- {
- FILE *fi;
- fi=fopen(VaultCfg,"w");
- fprintf(fi,"VaultLevel 200\n");
- fclose(fi);
- }
- int GetVaultLevel(void)
- {
- FILE *fi;
- char temp[100];
-
- fi=fopen(VaultCfg,"r");
- if(fi==NULL) return(200);
- while(fgets(temp,80,fi)!=NULL)
- {
- strupr(temp);
- if(!strnicmp(temp,"VERBOSE",7)) Verbose=TRUE;
- if(!strnicmp(temp,"VaultLevel ",11))
- {
- fclose(fi);
- return(atoi(&temp[11]));
- }
- }
- fclose(fi);
- return(200);
- }
-
- int Secure(char *s)
- {
- FILE *fi;
-
- BOOL found=FALSE;
- register int i;
- register int j;
- BOOL gotpass=FALSE;
- InitPass();
- fi=fopen(VaultCfg,"r");
- if(fi==NULL) return(0);
- i=0;
- while(fgets(temp,80,fi)!=NULL)
- {
- StripReturn(temp); strupr(temp);
- if(!strcmp(temp,s))
- {
- found=TRUE;
- while(fgets(temp,80,fi)!=NULL)
- {
- if(gotpass && temp[0]!='#') break;
- StripReturn(temp);
- strupr(temp);
- if(!strnicmp(temp,"Access ",7))
- {
- tempsecure=atoi(&temp[7]);
- }
- if(temp[0]=='#' && i<5)
- {
- gotpass=TRUE;
- strcpy(Password[i],&temp[2]);
- i++;
- }
- }
- fclose(fi);
- break;
- }
- }
- if(!found) { fclose(fi); return(0); }
- ShowIntro();
- j=0;
- while(j<i)
- {
- if(!GetPass(j)) { sm("",1); return(0);}
- sm("",1);
- j++;
- }
- return(1);
-
- }
-
- int GetPass(int num)
- {
- char Temp[100];
- register int i;
- register int j;
- char pass[200];
- i=3;
- if(Password[num][0]=='\0') return(1);
- while(i)
- {
- sprintf(Temp,"Vault password (%d) >: ",num+1);
- sm("",1);
- sm(Temp,0);
- strcpy(Temp,Password[num]);
- j=0;
- do
- {
- hk("",Temp);
-
- if(Temp[0]=='\b')
- {
- if(j==0) continue;
- sm("\b \b",0); j--; continue;
- }
- strupr(Temp);
- if(Temp[0]!=13 && Temp[0]!=12) {pass[j]=Temp[0]; sm("X",0); j++;}
- }
- while(Temp[0]!=13 && Temp[0]!=12 && j<30);
- pass[j]='\0';
- if(!strcmp(pass,Password[num])) return(1);
- sm("",1);
- i--;
- }
- return(0);
- }
- void ShowIntro(void)
- {
- if(!Verbose) return;
- sm("",1);
- sm(" .--------------------------------------------------------------------------.",1);
- sm(" | Ami-Express Vault Version 1.1 Written by ByteMaster |",1);
- sm(" | /X Development Team - The Silent Achievers |",1);
- sm(" `--------------------------------------------------------------------------'",1);
- sm("",1);
- }
- void InitPass(void)
- {
- register int i=0;
- while(i<5) { strcpy(Password[i],""); i++;}
- }
-